import 'reflect-metadata';
import {INJECTED_TOKENS} from './constant'
export function Inject(provide:string):ParameterDecorator{
    return function(target:Object,propertyKey:string,parameterIndex:number){
        // taget 类，propertyKey方法的名称，parameterIndex参数的索引
        const existingInjectTokens = Reflect.getMetadata(INJECTED_TOKENS,target) ?? [];
        // [0,1] == [empty,'StringToken']
        existingInjectTokens[parameterIndex] = provide;
        // 把数组保存在target的元数据上
        Reflect.defineMetadata(INJECTED_TOKENS,existingInjectTokens,target);
    }
}